#include <iostream>
#include <vector>
#include <algorithm>

struct Window {
    int id;
    int totalTime;
    std::vector<int> customers;
} windows[3];


bool MyCompare(const Window& w1, const Window& w2) {
    if (w1.totalTime != w2.totalTime) {
        return w1.totalTime < w2.totalTime;
    }
    return w1.id < w2.id;
}

bool MyCompare2(const Window& w1, const Window& w2) {
    return w1.totalTime < w2.totalTime;
}

/**
 * 
 * 业务办理时间
 */
int main() {

    for (int i=0; i < 3; i++) {
        windows[i].id = i+1;
    }

    int N;
    std::cin >> N;

    for (int i = 1; i <= N; i++) {
        int time;
        std::cin >> time;

        std::sort(windows, windows + 3, MyCompare);

        windows[0].totalTime += time;
        windows[0].customers.push_back(i);

    }

    std::sort(windows, windows + 3, MyCompare2);

    std::cout << windows[0].totalTime << "\n";
    for (int i=0; i < windows[0].customers.size(); i++) {
        std::cout << windows[0].customers[i] << " ";
    }


    return 0;
}
